
<div style="margin: 10px 10px 10px 10px">
    <form class="layui-form layui-form-pane" action="">
        <div class="layui-form-item">
              <div class="layui-inline">
                <div class="layui-input-inline">
                  <input id="s_time" type="text" name="s_time" lay-verify="required"  placeholder="开始时间" autocomplete="off" class="layui-input">
                </div>
              </div>
              <div class="layui-inline">
                <div class="layui-input-inline">
                  <input id="e_time" type="text" name="e_time" lay-verify="required"  placeholder="结束时间" autocomplete="off" class="layui-input">
                </div>
              </div>
            <div class="layui-inline" >
              <div class="layui-input-inline" style="width: 300px">
                <select name="chose_device" id="chose_device" xm-select="select" xm-select-type="1"  xm-select-search="" xm-select-height="36px" >
                </select>
              </div>
            </div>
            <div class="layui-inline">
                <a class="layui-btn" lay-submit="" lay-filter="data-search-btn">查询</a>
            </div>
        </div>
    </form>
</div>
<!-- 报警数据表格开始 -->
<table class="layui-table" id="report_table" lay-filter="report_table"></table>
<script type="text/html" id="alarm_report_bar">
    <a class="layui-btn layui-btn-xs " lay-event="show_alarm_detail">图表展示</a>
</script>
<!-- 报警数据表格结束 -->

<!-- js代码开始 -->

<script type="text/javascript">

form.render()
// 图标的宽度和高度的适应屏幕处理

$.ajax({
        type: 'GET',
        url:"/sys_log_web/?what=get_log_data",
        async:true,
        dataType: 'json',
        success: function(data) {
          console.log('success',data)
          report_table(data)
        },
        error:function(e){
          console.log(e)
        }
    });

// 设备数据表格渲染函数
var report_table=function(table_data){
  table.render({
    elem: '#report_table',
    data: table_data,
    toolbar: true,
    title:'报警数据',
    id:'report_table',
    cols: [
    [   {
        field: 'username', 
        title: '操作用户',
        sort:true,
        }
      , {
        field: 'visible_name',
        title: '用户名称',
       
    }, 
    {
        field: 'content',
        title: '操作内容',
        
    }, {
        field: 'result',
        title: '结果',
    },   {
        field: 'date_added',
        title: '操作时间',

    }  
    ]],
    limits: [10, 15, 20, 25, 50, 100],
    limit: 10,
    page: true
  });
}


// 监听设备搜索操作
form.on('submit(data-search-btn)', function (data) {
  var search_key = data.field;
  var s_time=search_key['s_time'];
  var e_time=search_key['e_time'];
  // console.log(formSelects.value('select', 'val'))
  query_param={'hard_id':formSelects.value('select', 'val'),'s_time':s_time,'e_time':e_time,'query_detail':'no'}
  post_info_ajax(query_param,'sys_log_web','query_log',report_table)
  return false;
});


//添加选择设备列表
fill_option(user_data,'chose_device','visible_name','username')
$('#chose_device').append('<option value="'+user_self.username+'">'+user_self.visible_name+'</option>')
formSelects.render() 

// 时间选择框渲染
laydate.render({
  elem: '#s_time'
  ,type: 'datetime'
  ,value:new Date(new Date(new Date().toLocaleDateString()).getTime())
  ,btns: ['clear','now', 'confirm']
});

laydate.render({
  elem: '#e_time'
  ,type: 'datetime'
  ,value:new Date()
  ,btns: ['clear','now', 'confirm']
});

</script>